<template>
  <view>
    <home-card :info="info"></home-card>
  </view>
  <view class="swiper">
	  <swiper-little></swiper-little>
  </view>
</template>

<script>
export default {
  data() {
    return {
      info: '',
    };
  },
  onLoad() {
    this.getInfo();
  },
  methods: {
    /**
     * 获取用户信息
     */
    getInfo() {
      //1.获取token
      const token = uni.getStorageSync('token');
      if (!token) {
        //token不存在，表示没有登录
        uni.navigateTo({
          url: '/pages/login/login',
        });
      }

      uni.request({
        url: "http://127.0.0.1:8001/app/user/info/person",
        method: "GET",
        header: {
          Authorization: token,
        },
        success: ({ data }) => {
          console.log('=== 用户信息获取成功', data);
          this.info = data;
          console.log('info', this.info);
        },
      });
    },
  },
};
</script>

<style scoped>
.swiper{
	margin-top: 30rpx;
}
</style>
